import Editor from "../editor";
import {Operation} from "../types";

export class InsertTextOperation implements Operation {
    spacers_: string;
    private insertIndex_: number;

    constructor(spacers: string, insertIndex: number) {
        this.spacers_ = spacers
        this.insertIndex_ = insertIndex
    }

    apply(editor: Editor): void {
        editor.getTextModel().insert(this.insertIndex_, this.spacers_)
    }

    inverse(editor: Editor): void {
        editor.getTextModel().remove(this.insertIndex_, this.insertIndex_ + this.spacers_.length)
    }

}